<template>
  <div id="app">

    <van-loading
      size="65px"
      text-size="16px"
      v-show="$store.state.loading"
    ></van-loading>
    <router-view v-if="isRouterAlive" />
    <transition name="van-fade">
      <Tabbar v-if="$route.meta.isShowTabbar" />
    </transition>

  </div>
</template>
<script>
import Tabbar from "@/components/Tabbar.vue";
export default {
  components: { Tabbar },
  //将控制<router-view>渲染的函数提供给子组件,让子组件需要更新时调用.
  data() {
    return { isRouterAlive: true };
  },
  provide() {
    return { reload: this.reload };
  },
  methods: {
    reload() {
      this.isRouterAlive = false; //先关闭，
      //需要在下一次DOM渲染完成之后调用。不能在created钩子调用，不起作用。
      this.$nextTick(function () {
        console.log("重新渲染页面");
        this.isRouterAlive = true; //再打开
      });
    },
  },
};
</script>

<style lang="less" scoped>
//这个会影响$toast.loading加载提示的样式
.van-loading {
  position: fixed !important ;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
}
</style>

<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: #efefef;
  min-height: 100%;
}
</style>
